<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    function fun(str) {
        // 截取字符串并反转
        var arr = str.split().reverse()
        // 获得数组
        arr[0] = '啊'
        arr[1] = '你爱我'
        arr[3] = 'olleH'
        arr[2] = 'dlroW'
        var num = ''
        for (let i = 0; i < arr.length; i++) {
            num += arr[i]
            console.log(num);
        }
    }
    fun('Hello World 我爱你！')
</script>
